﻿using System.IO;

using FirstFloor.Documents.Controls.Commands;
using FirstFloor.Documents.IO;
using FirstFloor.Documents.Pdf;

namespace FirstFloor.Documents.Presentation.Commands
{
    /// <summary>
    /// The command that opens a PDF document from disk and assigns it to a DocumentDataSource.
    /// </summary>
    public class OpenPdfFromDiskCommand
        : OpenFromDiskCommand
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="OpenPdfFromDiskCommand"/> class.
        /// </summary>
        public OpenPdfFromDiskCommand()
        {
            this.Filter = "PDF Documents (*.pdf)|*.pdf|All Files (*.*)|*.*";
        }

        /// <summary>
        /// Creates a package reader for given stream.
        /// </summary>
        /// <param name="stream">The stream.</param>
        /// <returns></returns>
        public override IPackageReader CreatePackageReader(Stream stream)
        {
            return new PdfDocumentReader(stream);
        }
    }
}
